/**
 * 解除 store 状态传递
 * @param {*} row 
 * @returns 
 */
function freeStore(row) {
    let str = JSON.stringify(row)
    return JSON.parse(str)
}
/**
 * 树形数据过滤
 * @param {*} treeData 
 * @param {*} searchValue 
 * @returns 
 */
function treeFilter(treeData, searchValue) {
    if (!treeData || treeData.length === 0) {
        return [];
    }
    const array = [];
    for (let i = 0; i < treeData.length; i += 1) {
        let match = false;
        for (let pro in treeData[i]) {
            if (typeof (treeData[i][pro]) == 'string') {
                match |= treeData[i][pro].includes(searchValue);
                if (match) break;
            }
        }
        if (treeFilter(treeData[i].children, searchValue).length > 0 || match) {
            array.push({
                ...treeData[i],
                children: treeFilter(treeData[i].children, searchValue),
            });
        }
    }
    return array;
}
export default {
    freeStore,
    treeFilter
}